package com.hncatv.snailantennae;

import com.hncatv.snailantennae.enums.LTPType;
import com.hncatv.snailantennae.thread.SnailPoolExecutor;

import java.util.Map;
import java.util.concurrent.FutureTask;


/**
 * 统计入口
 */
public final class SnailEvent {


    /**
     * pageview 屏幕值
     *
     * @param sn  screen 屏幕值,例`Android/主页/好物`
     * @param ltp 屏幕加载方式
     */
    public static void screen(String sn, LTPType ltp) {
        screen(sn, ltp, null);
    }




    /**
     * pageview 屏幕值
     *
     * @param sn  screen 屏幕值,例`Android/主页/好物`
     * @param ltp 屏幕加载方式
     * @param ecp event custom Parameters 自定义参数Map<key,value>
     */

    public static void screen(String sn, LTPType ltp, Map ecp) {

        try {
            ScreenTask screenTask =new ScreenTask(sn,ltp,ecp);
            SnailPoolExecutor.getInstance().execute(new FutureTask<Object>(screenTask,null));
        } catch (Exception e) {
            e.printStackTrace();
            ELogger.logWrite(SnailConstant.TAG, "expose " + e.getMessage());

        }


    }




    /**
     * 点击事件
     *
     * @param ecp event custom Parameters 自定义参数Map<key,value>
     */
    public static void eventIPanel(String service, String event_time, String userId,String region,String deviceId,String ca,String stb,Map ecp) {

        try {
            IPanelEventTask eventTask =new IPanelEventTask(service,event_time,userId,region,deviceId,ca,stb,ecp);
            SnailPoolExecutor.getInstance().execute(new FutureTask<Object>(eventTask,null));
        } catch (Exception e) {
            e.printStackTrace();
            ELogger.logWrite(SnailConstant.TAG, "event error " + e.getMessage());

        }





    }





    /**
     * 曝光
     * @param exposeID 去重用
     * @param ec  event category 事件类别
     * @param ea  event action 事件操作
     * @param ecp event custom Parameters 自定义参数Map<key,value>
     */
    public static synchronized void expose(String exposeID, String ec, String ea, Map ecp) {

        // expose(exposeID, ec, ea, ecp, null);

        try {
            ExposeTask exposeTask =new ExposeTask(exposeID,ec,ea,ecp);

            SnailPoolExecutor.getInstance().execute(new FutureTask<Object>(exposeTask,null));
        } catch (Exception e) {
            e.printStackTrace();
            ELogger.logWrite(SnailConstant.TAG, "expose error " + e.getMessage());

        }


    }


}
